{template header}
<style type="text/css">
    img.postImg {height: 100px;}
    img.header {max-height: 40px; max-width: 40px;}
    .span6 button{margin-top:10px;height: 45px;}
    .thumbnail > a > img {display: block;margin-left: auto;margin-right: auto;max-width: 100%;}
</style>
<script src="static/bootstrap/js/utils.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $("ul.thumbnails li input[type='checkbox']").click(function(){
            if($(this).prop("checked") == true) {
                checkSelectImg();
            }
            showSubmitButton();
        });
    });
    // 检查选择的图片
    function checkSelectImg()
    {
        var uid = 0;  // 用户ID
        var num = 0;  // 选择的图片数量
        $("ul.thumbnails li input[type='checkbox']").each(function(){
            if($(this).prop("checked") == true) {
                var thisUser = $(this).siblings("input#uid").val();
                var isOk = 1;
                if(Utils.isEmpty(thisUser))
                {
                    alert('发帖用户不存在');
                    isOk = 0;
                }
                else if(Utils.isEmpty(uid))
                {
                    uid = thisUser;
                }
                else if(uid != thisUser)
                {
                    alert('选择的图片不是来自于同一个用户');
                    isOk = 0;
                }
                num += 1;
                if(num > 3)
                {
                    alert('选择的图片数量不能大于3');
                    isOk = 0;
                    
                }
                if(isOk == 0) {
                    $(this).prop("checked", false);
                    return false;
                }
            }
        });
        return true;
    }
    // 显示/隐藏提交按钮
    function showSubmitButton()
    {
        var num = 0;  // 选择的图片数量
        $("ul.thumbnails li input[type='checkbox']").each(function(){
            if($(this).prop("checked") == true) {
                num += 1;
            }
        });
        if(num == 3) {
            $("#submitDiv").removeClass("hidden");
        } else {
            $("#submitDiv").addClass("hidden");
        }
        return true;
    }
</script>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <form class="form-horizontal" action="index.php?c=admin&a=setRecFriend" method="post">
            <div class="alert alert-success hidden" id="submitDiv">
                <button class="btn btn-primary btn-block" type="submit">提交按钮必须要长</button>
            </div>
            <ul class="thumbnails">
                {loop $list $k $v}
                <li class="span2">
                    <div class="thumbnail">
                        <div class="float-top-left">
                            <input type="checkbox" name="key[]" value="{$k}" id="userImgSelect_{$k}">
                            <input type="hidden" name="user[{$k}]" value="{$v['uid']}">
                            <input type="hidden" name="postImg[{$k}]" value="{$v['img']}">
                            <input type="hidden" id="uid" value="{$v['uid']}">
                        </div>
                        <a href="#postImg_{$k}" data-toggle="modal">
                            <img class="postImg" src="{$v['img']}" />
                        </a>
                        <div id="postImg_{$k}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                <h3 id="myModalLabel">帖子大图</h3>
                            </div>
                            <div class="modal-body" style="height:700px;">
                                <img src="{$v['img']}">
                            </div>
                        </div>
                        <div class="row-fluid">
                            <div class="span4">
                                <img class="header img-circle" src="{$v['header']}" />
                            </div>
                            <div class="span6">
                                <a href="index.php?c=admin&a=userPostImgs&uid={$v['uid']}">
                                    <button class="btn btn-block btn-info" type="button">{$v['nickname']}</button>
                                </a>
                            </div>
                        </div>
                    </div>
                </li>
                {/loop}
            </ul>
            </form>
        </div>
    </div>
</div>
{template footer}